package com.wheelpicker.picker;

import android.os.Bundle;
import android.view.View;

import com.wheelpicker.base.BasePickerDialog;
import com.wheelpicker.picker.nolinkpicker.NoLinkPickerConfig;
import com.wheelpicker.picker.nolinkpicker.NoLinkWheel;
import com.wheelpicker.picker.nolinkpicker.SinglePickerBean;

import java.util.List;

/**
 * Created by jzxiang on 16/4/19.
 */
public class NoLinkPickerDialog extends BasePickerDialog<NoLinkPickerConfig> {


    private NoLinkWheel noLinkWheel;

    private static NoLinkPickerDialog newInstance(Builder builder) {
        NoLinkPickerDialog noLinkPickerDialog = new NoLinkPickerDialog();
        Bundle bundle = getArgumentBundle(builder);
        noLinkPickerDialog.setArguments(bundle);
        noLinkPickerDialog.initialize(builder.mPickerConfig);
        return noLinkPickerDialog;
    }

    @Override
    protected void initialize(NoLinkPickerConfig pickerConfig) {
        mPickerConfig = pickerConfig;
    }

    @Override
    protected void initCustomView(View view) {
        noLinkWheel = new NoLinkWheel(view, mPickerConfig);
    }

    protected void onSureClicked() {
        List<SinglePickerBean> pickerBeanList = noLinkWheel.getCurrentPickerBean();
        if (mDialogResultListener != null)
            mDialogResultListener.result(this, pickerBeanList);
    }

    public static class Builder extends BasePickDialogBuild<NoLinkPickerConfig, Builder, NoLinkPickerDialog> {

        public Builder() {
            mPickerConfig = new NoLinkPickerConfig();
        }

        public Builder setAddressList(List<List<SinglePickerBean>> datas) {
            mPickerConfig.pickerBeanList = datas;
            return this;
        }

        @Override
        public NoLinkPickerDialog build() {
            return NoLinkPickerDialog.newInstance(this);
        }

    }
}
